/**
 * 全局路由
 */
class Router {
    constructor() {
        this.router = {
            'chart': '/pages/chart/chart.html',
            'member': '/pages/member/member.html',
            'list': '/pages/member/list.html',
            'aaa': '/pages/bbbb/aaa.html',
            'employee_manage': '/pages/employee_manage/employee_manage.html',
            'employee_add': '/pages/employee_manage/employee_add.html',
            'user/edit/': '/pages/employee_manage/employee_add.html',
            'demo': '/pages/demo/demo.html',
            'mapped': '/pages/mapped/mapped.html',
            'mapped_add': '/pages/mapped/mapped_add.html',
            'tdrag_demo': '/pages/tdrag/tdrag_demo.html',
            'datasource_manage':'/pages/datasource_manage/datasource_manage.html',
            'details':'/pages/details/details.html',
            'details_group':'/pages/details/details_group.html',
            'missions':'/pages/missions/missions.html',
            'management':'/pages/management/management.html'
        }
    }

    get(key) {
        let url = this.router[key];
        if (!url) {
            url = key;
            u.log(`未找到此路由:${key}`)
        }
        return url;
    }
    set(key, value) {
        let router = store.get('router') || {};
        router[key] = value;
        store.set('router', router)
    }
    to(key, params = {}) {
        let paramsStr = u.toUrl(params);
        pjaxInit(`/workshop?key=${key}&${paramsStr}`.replace(/\&$/, ''));
    }
}
let router = new Router();
